﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using CanDienTu_WS.Models;
namespace CanDienTu_WS
{
	#region Using
	using CanDienTu_WS.Models;
	using CanDienTu_WS.Repositories;
	using CanDienTu_WS.Helpers;
	using CanDienTu_WS.DTO;
	#endregion
	public class CanDienTu_Service: ICanDienTu_Service
	{
		/////////////////// DULIEU ///////////////////
		public List<DuLieuDTO> DuLieu_SelectAll()
		{
			var lstDto = new List<DuLieuDTO>();
			var rpt = new DuLieuRepository();
			var lstEntity = rpt.SelectAll();
			foreach (var item in lstEntity)
			{
				lstDto.Add(DuLieuDTO.Translate(item));
			}
			return lstDto;
		}

		public DuLieuDTO DuLieu_SelectByID(string id)
		{
			var rpt = new DuLieuRepository();
			return DuLieuDTO.Translate(rpt.SelectByID(int.Parse(id)));
		}

		public bool DuLieu_Insert(DuLieuDTO obj)
		{
			var rpt = new DuLieuRepository();
			var entity = DuLieuDTO.Reverse(obj);
			return rpt.Insert(entity);
		}

		public bool DuLieu_Delete(string id)
		{
			var rpt = new DuLieuRepository();
			return rpt.Delete(int.Parse(id));
		}

        public string test_service()
        {
            return "le sy tuan";
        }
	}
}
